/**
 * Joint 0.4 - JavaScript diagramming library.
 * Copyright (c) David Durman 2009 - 2011
 * Licensed under the MIT license: (http://www.opensource.org/licenses/mit-license.php)
 */
(function(e) {
    var f = e.Joint;
    e = f.dia.Element;
    var g = f.dia.org = {};
    g.arrow = {startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none","stroke-width":2,stroke:"gray"}};
    g.Member = e.extend({object:"Member",module:"org",init:function(a) {
        a = f.DeepSupplement(this.properties, a, {attrs:{fill:"lightgreen",stroke:"#008e09","stroke-width":2},name:"",position:"",nameAttrs:{"font-weight":"bold"},positionAttrs:{},swimlaneAttrs:{"stroke-width":1,stroke:"black"},labelOffsetY:10,radius:10,shadow:true, avatar:"",padding:5});
        this.setWrapper(this.paper.rect(a.rect.x, a.rect.y, a.rect.width, a.rect.height, a.radius).attr(a.attrs));
        if (a.avatar) {
            this.addInner(this.paper.image(a.avatar, a.rect.x + a.padding, a.rect.y + a.padding, a.rect.height - 2 * a.padding, a.rect.height - 2 * a.padding));
            a.labelOffsetX = a.rect.height
        }
        if (a.position) {
            a = this.getPositionElement();
            this.addInner(a[0]);
            this.addInner(a[1])
        }
        this.addInner(this.getNameElement())
    },getPositionElement:function() {
        var a = this.properties,c = this.wrapper.getBBox(),d = this.paper.text(c.x + c.width / 2, c.y + c.height / 2, a.position).attr(a.positionAttrs || {}),b = d.getBBox();
        d.translate(c.x - b.x + a.labelOffsetX, c.y - b.y + b.height);
        b = d.getBBox();
        a = this.paper.path(["M",b.x,b.y + b.height + a.padding,"L",b.x + b.width,b.y + b.height + a.padding].join(" "));
        return[d,a]
    },getNameElement:function() {
        var a = this.properties,c = this.wrapper.getBBox(),d = this.paper.text(c.x + c.width / 2, c.y + c.height / 2, a.name).attr(a.nameAttrs || {}),b = d.getBBox();
        d.translate(c.x - b.x + a.labelOffsetX, c.y - b.y + b.height * 2 + a.labelOffsetY);
        return d
    }})
})(this);